package com.anyuan.wx.main;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.anyuan.wx.menu.Button;
import com.anyuan.wx.menu.ClickButton;
import com.anyuan.wx.menu.ComplexButton;
import com.anyuan.wx.menu.Menu;
import com.anyuan.wx.menu.ViewButton;
import com.anyuan.wx.pojo.AccessToken;
import com.anyuan.wx.util.CommonUtil;
import com.anyuan.wx.util.MenuUtil;


public class MenuManager
{
	private static Logger log = LoggerFactory.getLogger(MenuManager.class);
	
	public static void main(String[] args)
	{
	
		//@车服务
		String appid = "wx9bd6bd48e69439f1";
		
		String appSecret = "3cd1f2d7298948529644f70083e91213";
//		//清华大学苏州汽车研究院
//		String appid = "wx6ad6baebd4c08891";
//		
//		String appSecret = "7df2fe5e844f645941eac73aa83d7e41";
		
		AccessToken accessToken = CommonUtil.getAccessToken(appid, appSecret);
		
		if(null != accessToken)
		{
			boolean result = MenuUtil.createMenu(accessToken.getToken(), getMenu());
			if(true==result)
				log.info("菜单创建成功");
			else {
				log.info("菜单创建失败"+result);
			}
		}	
		
	}
	
	public static Menu getMenu() 
	{
		
		
		ViewButton btn11 = new ViewButton();
		btn11.setName("清研资讯");
		btn11.setUrl("http://www.tsari.tsinghua.edu.cn");
		btn11.setType("view");
		
		ViewButton btn12 = new ViewButton();
		btn12.setName("汽车大全");
		btn12.setUrl("http://a.xcar.com.cn/newcar/0-0-0-0-0-0-true/");
		btn12.setType("view");
		
		ViewButton btn13 = new ViewButton();
		btn13.setName("空气质量");
		btn13.setUrl("http://www.anyuantech.com/");
		btn13.setType("view");
		
		ViewButton btn14 = new ViewButton();
		btn14.setName("水质周报");
		btn14.setUrl("http://app.zjepb.gov.cn:8080/wasdemo/search?channelid=166918");
		btn14.setType("view");
		
		ViewButton btn21 = new ViewButton();
		btn21.setName("实时路况");
		btn21.setUrl("http://www.sijibang.com/index/wxmap");
		btn21.setType("view");
		
		ClickButton btn22 = new ClickButton();
		btn22.setName("保养预约");
		btn22.setKey("22");
		btn22.setType("click");
		
		ClickButton btn23 = new ClickButton();
		btn23.setName("车辆位置");
		btn23.setKey("location");
		btn23.setType("click");
		
		ClickButton btn24 = new ClickButton();
		btn24.setName("故障救援");
		btn24.setKey("24");
		btn24.setType("click");
		
		ClickButton button31 = new ClickButton();
		button31.setName("会员");
		button31.setKey("31");
		button31.setType("click");
		
		ClickButton button32 = new ClickButton();
		button32.setName("我的积分");
		button32.setKey("32");
		button32.setType("click");
		
		ClickButton button33 = new ClickButton();
		button33.setName("反馈意见");
		button33.setKey("33");
		button33.setType("click");
		
		ClickButton button34 = new ClickButton();
		button34.setName("服务点评");
		button34.setKey("34");
		button34.setType("click");
		
		ComplexButton button1 = new ComplexButton();
		button1.setName("车联资讯");
		button1.setSub_button(new Button[]{btn11,btn12,btn13,btn14});

		ComplexButton button2 = new ComplexButton();
		button2.setName("车联服务");
		button2.setSub_button(new Button[]{btn21,btn22,btn23,btn24});
		
		ComplexButton button3 = new ComplexButton();
		button3.setName("别点我");
		button3.setSub_button(new Button[]{button31,button32,button33,button34});
		
		Menu menu = new Menu();
		menu.setButton(new Button[]{button1,button2,button3});
		return menu;
	}

}
